package com.kira.scaffoldmvc.Config;

import com.kira.scaffoldmvc.Interceptor.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

//配置我们的拦截器
@Configuration
public class WebConfig implements WebMvcConfigurer {

//这个是在配置类里面来注册我们的拦截器
    @Autowired
    private LoginInterceptor loginInterceptor;
    @Override
    public void addInterceptors(InterceptorRegistry registry) {

        registry.addInterceptor(loginInterceptor).order(1)
                .excludePathPatterns("/xxxx/xxxx","/xxxx/xxxx")//配置放行路径
                .addPathPatterns("/**");//拦截路径，/**拦截所有


    }
}
